<template>
	<view class="padb20">
		<stop isBack>
			<view slot="content">设备保养</view>
		</stop>
		<view class="pad3 bcf">
			<view class="list-style-1">当前设备</view>
		</view>
		<view class="pad3 bcf bdtda" v-if="isbool(objval(en,['machine']))">
			<view class="bc13 pad2">
				<machine :itemId="en.machine.id"></machine>
			</view>
		</view>
		<view class="pad3 bcf mart3">
			<view class="list-style-1">基本信息</view>
		</view>
		<view>
			<sentity label="保养等级" model="MachineMaintainLevel" v-model="en.level" placeholder="请选择"></sentity>
		</view>
		<view>
			<stext label="保养费用"  v-model="en.fee" placeholder="请输入"></stext>
		</view>
		
		
		<view class="padlr3 mart3" v-if="isbool(en)">
			<view class="bcf mart3 round5 shadow-blur" v-for="item in en.pointLog" :key="item.id">
				<view class="flrc bg-gradual-blue round3 padlr3 pos-r ofh">
					
					<view class="padr2 fs12">
						<text class="fa fa-angle-right"></text>
					</view>
					<view class="">保养项目</view>
					<view class="flex1 tar padtb3 ofe">
						{{item.maintainPoint.name}}
					</view>
					<ripple></ripple>
				</view>
				<view class="bdbda padb2 bdw3 marlr2">
					<!-- <view class="flrc bdbda pad2">
						<view class="c12">注意事项</view>
						<view class="flex1 tar padtb3">
							{{item.maintainPoint.tips}}
						</view>
					</view> -->
					<radio-group class="block flex1 tal">
						<view @tap="item.note = choice " class="pad2 flrc round pos-r"  v-for="choice in item.maintainPoint.choices">
							<view class="padr3 flex1 round padl3">{{choice}}</view>
							<view>
								<radio :class="choice == item.note?'checked':''" :checked="choice == item.note?'checked':false" :value="choice"></radio>
							</view>
							<ripple></ripple>
						</view>
					</radio-group>
				</view>
				<view class="pad2">
					
					<view class="list-style-2 flrc">
						<view class="flex1">结果记录</view>
					</view>
					<view class="bdtda mart2">
						<stextarea label="备注" v-model="item.tips"></stextarea>
					</view>
					<view class="bdtda">
						<spics label="附件" v-model="item.pics"></spics>
					</view>
				</view>
			</view>
		</view>
		
		<view class="lh2 bcf pad2 bdtso pos-f l0 r0 b0">
			<view class="tac pad2 line-green round cu-btn lg w100 " @tap="submit">
				<view>提交</view>
				<ripple></ripple>
			</view>
		</view>
		<loading :loading="myIsLoading"></loading>
	</view>
</template>

<script>
	import machine from '../../templete/machine/machine_item.vue'
	export default {
		components:{machine},
		data() {
			return {
				id:"",
				en:{}
			}
		},
		methods: {
			submit(){
				this.log(this.en.checkItems)
				
				if(this.isnull(this.en.level)){this.$com.showToast('选择保养等级');return;}
				if(this.isnull(this.en.fee)){this.en.fee = 0}
				this.$api.put('/api/submit/machineMaintainOrders',this.en,(res)=>{
					this.log(res)
					if(res.s == 1){
						this.$win.goback()
					}else{
						this.$com.showToast(res.i)
					}
				})
			}
		},
		onLoad(option) {
			this.showLoading()
			this.id = option.id
			if(this.isbool(this.id)){
				this.$api.get("/api/machineMaintainOrders/" + this.id, {},(res)=>{
					this.clearLoading()
					this.log(res)
					this.clearLoading()
					this.en = res.d
				})
			}
		}
	}
</script>

<style>

</style>
